<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>操作</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="threaded.isterminated.html">« Threaded::isTerminated</a></li>
      <li style="float: right;"><a href="threaded.notify.html">Threaded::notify »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.threaded.html">Threaded</a></li>
    <li>操作</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="threaded.merge" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Threaded::merge</h1>
  <p class="verinfo">(PECL pthreads &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Threaded::merge</span> &mdash; <span class="dc-title">操作</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-threaded.merge-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span><span class="methodname"><strong>Threaded::merge</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$from</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$overwrite</code><span class="initializer"> = ?</span></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   将数据合并到当前对象
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-threaded.merge-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>

     <code class="parameter">from</code>
    </dt>

    <dd>

     <p class="para">
      要合并的数据
     </p>
    </dd>

   
   
    <dt>

     <code class="parameter">overwrite</code>
    </dt>

    <dd>

     <p class="para">
      如果现有对象已经存在同键的数据，是否覆盖。默认为 true
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-threaded.merge-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-threaded.merge-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3321">
    <p><strong>示例 #1 合并数据到对象的属性表</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$array&nbsp;</span><span style="color: #007700">=&nbsp;[];<br /><br />while&nbsp;(</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$array</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$stdClass&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">stdClass</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$stdClass</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">foo&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stdClass</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bar&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"bar"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$stdClass</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">baz&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"baz"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$safe&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Threaded</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$safe</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">merge</span><span style="color: #007700">(</span><span style="color: #0000BB">$array</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$safe</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">merge</span><span style="color: #007700">(</span><span style="color: #0000BB">$stdClass</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$safe</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
object(Threaded)#2 (13) {
  [&quot;0&quot;]=&gt;
  int(0)
  [&quot;1&quot;]=&gt;
  int(1)
  [&quot;2&quot;]=&gt;
  int(2)
  [&quot;3&quot;]=&gt;
  int(3)
  [&quot;4&quot;]=&gt;
  int(4)
  [&quot;5&quot;]=&gt;
  int(5)
  [&quot;6&quot;]=&gt;
  int(6)
  [&quot;7&quot;]=&gt;
  int(7)
  [&quot;8&quot;]=&gt;
  int(8)
  [&quot;9&quot;]=&gt;
  int(9)
  [&quot;foo&quot;]=&gt;
  string(3) &quot;foo&quot;
  [&quot;bar&quot;]=&gt;
  string(3) &quot;bar&quot;
  [&quot;baz&quot;]=&gt;
  string(3) &quot;baz&quot;
}
</pre></div>
    </div>
   </div>
  </p>
 </div>

</div></div></div></body></html>